<html>
<head>
	<meta charset="UTF-8">
	<title>注册次级域名分发系统管理员</title>
	<link rel="stylesheet" href="jquery-easyui-1.9.14/themes/default/easyui.css" />
	<link rel="stylesheet" href="jquery-easyui-1.9.14/themes/icon.css" />
	<script type="text/javascript" src="jquery-easyui-1.9.14/jquery.min.js"></script>
	<script type="text/javascript" src="jquery-easyui-1.9.14/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="jquery-easyui-1.9.14/locale/easyui-lang-zh_CN.js"></script>
	<script type='text/javascript' src='bug-min.js'></script>
	<style type="text/css">
		body{
			background-image:url('bg.svg');
		}
		table{
		    margin: auto;
		}
	</style>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes" />
	<style type="text/css"> 
		@media(max-width:960px){
			body {
				width:100%;
				background-image:url('bg.svg');
			} 
		}
	</style>
</head>
<body>
	<div id="dlg" class="easyui-dialog" title="注册管理员" style="width: 320px; height: 350px; padding: 10px">
		<form id="ff" method="post" action="/reg">
			<div style="margin-bottom: 18px">
				<b>用户:</b><input id="userid" name="userid" style="width: 100%" onblur="checkUserId()" />
				<div id="useridtip" style="font-size: 10px">
					<font color="red">尽量不要使用admin,root等常用用户名</font>
				</div>
			</div>
			<div style="margin-bottom: 18px">
				<b>密码:</b><input id="pwd" name="pwd" type="password" style="width: 100%" />
			</div>
			<div style="margin-bottom: 18px">
				<b>确认密码:</b><input id="rpwd" type="password" style="width: 100%" onblur="checkPwd()" />
				<div id="rpwdtip" style="font-size: 10px">
					<font color="red">请确认密码</font>
				</div>
			</div>
		</form>
		<a href="/loginPage"><font style="font-size: 10px">已有账号？点此登录</font></a>
	</div>


	<script>
		new BugController({'minBugs':1, 'maxBugs':1, 'mouseOver':'fly'});
		$('#dlg').dialog({
		    cache: false,
			iconCls: 'icon-man',
			resizable: false,
			closable: false,
		    modal: true,
			buttons: [{
				text:'注册',
				iconCls:'icon-ok',
				handler:function(){
					submitForm();
				}
			},{
				text:'重置',
				handler: function(){
					clearForm();
				}
			}]
		});
	
		function submitForm(){
			if(checkUserId()&&checkPwd()){
				$('#ff').submit();
			}
		}
		function clearForm(){
			$('#ff').form('clear');
		}
		function checkUserId(){
			var flag = false;
			var userid = $('#userid').val();
			if(userid==''){
				$('#useridtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/no.png' /><font color='red'>请输入用户名</font></div>");
			}
			else{
				$.ajax({
					type : "POST",
					url : "/chkUserId",
					data : {
						"userid" : userid
					},
					async : false,
					success : function(result) {
						if(result=="Y"){
							$('#useridtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/ok.png' /><font color='green'>用户名可用</font></div>");
							flag = true;
						}
						else{
							$('#useridtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/no.png' /><font color='red'>用户名不可用</font></div>");
						}
					},
					error : function(){
						$('#useridtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/no.png' /><font color='red'>用户名不可用</font></div>");
					}
				});
			}
			return flag;
		}
		function checkPwd(){
			var flag = false;
			var pwd1 = $('#pwd').val();
			var pwd2 = $('#rpwd').val();
			if(pwd1!=''&&pwd2!=''&&pwd1==pwd2){
				$('#rpwdtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/ok.png' /><font color='green'>密码一致</font></div>");
				flag = true;
			}
			else{
				$('#rpwdtip').html("<div><img src='jquery-easyui-1.9.14/themes/icons/no.png' /><font color='red'>两次密码不一致</font></div>");
			}
			return flag;
		}
	</script>

</body>
</html>
